class Solution:
    def uniquePathsWithObstacles(self, obstacleGrid) -> int:
        self.count = 0

        def DFS(i, j, size_i, size_j):
            if i == size_i or j == size_j:  # 不能越界
                return

            if i == size_i - 1 and j == size_j - 1:
                self.count += 1
                return
            DFS(i + 1, j, size_i, size_j)

            DFS(i, j + 1, size_i, size_j)

        DFS(0, 0, len(obstacleGrid), len(obstacleGrid[0]))
        return self.count

